Skip to content

feat: native C++ prefill bridge (dlopen) - #39

Merged
ekryski merged 1 commit into
ekryski:alphafrom
TheTom:pr/alpha-9-prefill-bridge
Apr 16, 2026
Merged

ekryski merged 1 commit into
ekryski:alphafrom
TheTom:pr/alpha-9-prefill-bridge

Conversation

@TheTom

@TheTom TheTom commented Apr 16, 2026

Copy link
Copy Markdown

Clean port from ek/tom-eric-moe-tuning. Part of alpha cleanup.

@ekryski ekryski left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be rebased off of one of #32 or following PRs for cleaner diff. Looks good though.

Is dependent on ekryski/mlx-swift#4

@TheTom
TheTom force-pushed the pr/alpha-9-prefill-bridge branch from 571cf07 to cbe547a Compare April 16, 2026 04:24
C++ prefill bridge bypasses Swift MLXArray/ARC overhead for 2-3x
faster prefill. Uses dlopen to avoid SPM LTO miscompilation.

- prefill_bridge_gemma.cpp: Gemma 4 forward pass (15 non-shared layers)
- prefill_bridge_qwen.cpp: Qwen MoE forward pass
- generic_prefill.cpp: Multi-architecture bridge
- GemmaPrefillBridge.swift: dlopen/dlsym bridge for Gemma 4
- QwenPrefillBridge.swift: Swift-side Qwen bridge integration
- build-prefill-bridge.sh: compile bridge dylib with clang++ -O3

Opt-in via NATIVE_PREFILL=1. Bridge shares host MLX allocator
via -undefined dynamic_lookup.

Note: Package.swift needs NativePrefillBridge target added separately.

Co-Authored-By: tturney1@gmail.com
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@TheTom
TheTom force-pushed the pr/alpha-9-prefill-bridge branch from cbe547a to 00ed2bf Compare April 16, 2026 04:36
@ekryski
ekryski merged commit 55d2428 into ekryski:alpha Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants